package edu.zut.cs.software.cms.module.information.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import edu.zut.cs.software.cms.base.web.spring.controller.GenericController;
import edu.zut.cs.software.cms.module.information.domain.Information;
import edu.zut.cs.software.cms.module.information.service.InformationManager;

/**
 * 
 * @author 42276
 *
 */
@Controller
@RequestMapping("/information")
public class InformationController extends GenericController<Information, Long, InformationManager> {
	InformationManager informationManager;

	@Autowired
	public void setInformationManager(InformationManager informationManager) {
		this.informationManager = informationManager;
		this.manager = this.informationManager;
	}

	@RequestMapping(method = RequestMethod.GET, value = "/index.html")
	public String index() {
		String result = "/clazz/index";
		return result;
	}

	@RequestMapping("/deleteOneInformation")
	@ResponseBody
	public String deleteOneInformation(long id) {
		if (informationManager.deleteById(id)) {
			informationManager.delete(id);
			return "delete success";

		} else
			return "failure";
	}

}